DesertCloud.hlsl 838 B

12345678910111213141516171819202122232425
  1. #ifndef LINE_KIT_DEMOS_DESERT_PILLAR_INCLUDED
  2. #define LINE_KIT_DEMOS_DESERT_PILLAR_INCLUDED
  3. #include "Noise/ClassicNoise2D.hlsl"
  4. float Hash(float x) {
  5. return frac(sin(x)) * 1000;
  6. }
  7. void CloudAlpha_float(float2 UV, float3 ObjectPositionWS, float3 ObjectScale, float3 PositionWS, out float Alpha) {
  8. const float hash = Hash(ObjectPositionWS.x + ObjectPositionWS.z);
  9. float noise = 0;
  10. const float2 p = (PositionWS.xz + hash) / ObjectScale.xz * _ScaleFactor;
  11. noise += ClassicNoise(p * _NoiseScale1 * 1.0) * 1.0;
  12. noise += ClassicNoise(p * _NoiseScale2 * 2.0) * 0.5;
  13. // Fade out close to UV edges.
  14. const float2 edgeDistances = saturate(abs(UV - 0.5) * 2.0 - 0.5);
  15. noise *= saturate(1.0 - length(edgeDistances) / _FadeOutDistance);
  16. Alpha = noise;
  17. }
  18. #endif // LINE_KIT_DEMOS_DESERT_PILLAR_INCLUDED